<!DOCTYPE html>
<html lang="zh">
<head>
    <title>付费知识管理</title>
    <{include file="article/public/header"}>
    <link rel="stylesheet" href="/static/adminlte/plugins/jsTree/style.min.css">
    <style>

        .jstree-default .jstree-anchor{
            height: 40px;
        }


    </style>

</head>
<body class="hold-transition sidebar-mini layout-fixed">
<!-- Site wrapper -->
<div class="wrapper">
    <!-- Navbar -->
    <{include file="article/public/navbar"}>
    <!-- /.navbar -->

    <!-- Main Sidebar Container -->
    <!--左侧菜单-->
    <{include file="article/public/sidebar"}>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">

                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="#">文章管理</a></li>
                            <li class="breadcrumb-item active">文章分类</li>
                        </ol>
                    </div>
                </div>
            </div>
        </section>
        <!-- Main content -->
        <section class="content">
            <div class="container-fluid">
                <div class="card">
                    <div class="card-header">
                        <div class="form-group">
                            <span class="btn btn-success add-data" title="新增"><i class="fas fa-plus"></i></span>

                        </div>
                    </div>
                    <div class="card-body">
                        <div class="wrapper wrapper-content animated fadeInRight">
                            <div class="row">
                                <div class="col-lg-12">
                                    <div class="ibox float-e-margins">
                                        <div class="ibox-title">
                                            <h5>分类管理 </h5>
                                        </div>
                                        <div class="ibox-content">
                                            <div id="jstree" class="jstree jstree-1 jstree-default" role="tree" aria-multiselectable="true" tabindex="0" aria-activedescendant=" " aria-busy="false">

                                                <{if !empty($data)}>
                                                <{foreach $data as $one}>
                                                <ul class="jstree-container-ul jstree-children" role="group">
                                                    <li role="treeitem" data-jstree='{"icon" : "fas list-alt"}' aria-selected="false" aria-level="1" aria-labelledby="j1_21_anchor" aria-expanded="true"  class="jstree-node jstree-node jstree-node   jstree-last  jstree-open">
                                                        <!--<i class="jstree-icon jstree-ocl" role="presentation"></i>-->
                                                        <a class="jstree-anchor jstree-anchor jstree-anchor" href="#" tabindex="-1" id="">
                                                            <i class="jstree-icon jstree-themeicon  jstree-themeicon-custom" role="presentation"></i>

                                                            <input type="hidden" name="ids" value="<{$one.id}>">
                                                            <{$one.name}>----<{if $one.status=='1'}><span class="bs-green" title="启用中"><i class="fas fa-check"></i></span><{else}><span class="bs-red" title="已禁用"><b>X</b></span><{/if}>------<span class="fas fa-edit bs-blue edit-data" data-id="<{$one.id}>" title="编辑"></span>~~~~
                                                            <span class="fas fa-trash-alt bs-red" onclick="del('<{$one.id}>',this)" title="删除" style="margin-left: 0px"></span>
                                                        </a>
                                                        <{if !empty($one['subcat'])}>
                                                        <ul role="group" class="jstree-children">
                                                            <{foreach $one['subcat'] as $two}>
                                                            <li role="treeitem" data-jstree='{"icon" : "fa fa-trash-o"}' aria-selected="false" aria-level="2" aria-labelledby="j1_22_anchor" aria-expanded="true" class="jstree-node jstree-node jstree-node    jstree-open">
                                                                <!-- <i class="jstree-icon jstree-ocl" role="presentation"></i>-->
                                                                <a class="jstree-anchor jstree-anchor jstree-anchor" href="#"  tabindex="-1" >
                                                                    <i class="jstree-icon jstree-themeicon  jstree-themeicon-custom"  role="presentation"></i>

                                                                    <input type="hidden" name="ids" value="<{$two.id}>">
                                                                    <{$two.name}>----<{if $two.status=='1'}><span class="bs-green" title="启用中"><i class="fas fa-check"></i></span><{else}><span class="bs-red" title="已禁用"><b>X</b></span><{/if}>------<span  class="fas fa-edit bs-blue edit-data" data-id="<{$two.id}>"  title="编辑"></span>~~~~
                                                                    <span  class="fas fa-trash-alt bs-red" onclick="del('<{$two.id}>',this)" title="删除" style="margin-left: 0"></span>
                                                                </a>
                                                                <{if !empty($two['subcat'])}>
                                                                <ul role="group" class="jstree-children">
                                                                    <{foreach $two['subcat'] as $three}>
                                                                    <li role="treeitem" data-jstree='{"icon" : "fa fa-trash-o"}' aria-selected="false" aria-level="3" aria-labelledby="j1_23_anchor" class="jstree-node jstree-node  jstree-leaf jstree-last jstree-leaf jstree-last">
                                                                        <!--<i class="jstree-icon jstree-ocl" role="presentation"></i>-->
                                                                        <a class="jstree-anchor  jstree-anchor  jstree-anchor" href="#" tabindex="-1"  >
                                                                            <i class="jstree-icon jstree-themeicon  jstree-themeicon-custom" role="presentation"></i>

                                                                            <input class="ids" type="hidden" name="ids" value="<{$three.id}>">
                                                                            <{$three.name}>----<{if $three.status=='1'}><span class="bs-green" title="启用中"><i class="fas fa-check"></i></span><{else}><span class="bs-red" title="已禁用"><b>X</b></span><{/if}>------
                                                                            <span class="fas fa-edit   bs-blue edit-data" data-id="<{$three.id}>" title="编辑"></span>
                                                                            ~~~~<span class="fas fa-trash-alt bs-red" onclick="del('<{$three.id}>',this)" title="删除" style="margin-left: 0"></span>
                                                                        </a>
                                                                    </li>
                                                                    <{/foreach}>
                                                                </ul>
                                                                <{/if}>
                                                            </li>
                                                            <{/foreach}>
                                                        </ul>
                                                        <{/if}>

                                                    </li>
                                                </ul>
                                                <{/foreach}>
                                                <{/if}>
                                            </div>

                                        </div>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
            </div>

        </section>
    </div>


</div>
<!-- ./wrapper -->

<{include file="article/public/footer"}>
<script src="/static/adminlte/plugins/jsTree/jstree.min.js"></script>
<script>


</script>
<script>
    $(function () {
        $('#jstree').jstree();
        $(".add-data").click(function () {
            openPage("<{:url('category_form')}>",'新增分类','600px','500px')
        });
        $(".edit-data").on('click',function () {
            var id = $(this).data('id');
            openPage("<{:url('category_form')}>?id="+id,'编辑分类','600px','500px')
        })
    });
    function del(id,obj){
        layer.confirm('确定要删除吗',{title:'删除确认',btn:['确定','点错了']},function (index) {
            sendData("<{:url('category_action')}>",{id:id,ac:'del'},function (res) {
                if (res.code==0){
                    $(obj).parent('a').parent('li').remove()
                    layer.close(index)
                }
            })

        })
    }


</script>
</body>
</html>
